<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>defineProperty</title>
</head>
<body>
  <div id="app"></div>
  <script>
    let el = document.getElementById('app');
    let data = {
      msg : 'hello'
    }
    el.innerHTML = data.msg;

    let vm = {}
    Object.defineProperty(vm, 'msg', {
      enumerable: true, 
      configurable: true, 
      get(){
        console.log(vm);
        return data.msg
      },
      set(value){
        data.msg = value
        el.innerHTML = vm.msg
      }
    })
    vm.msg = 'world'
    console.log(vm.msg);

  </script>
</body>
</html>